@layout("/common/_container.html"){
<style>
    .templateText{flex: 1;text-align: right}
    .templateFrame{flex: 5;margin-left: 20px;}
    .btnBox button {
        background: #30add1;
        color: white;
        border:1px solid #999999;
        width: 80px;
    }
    input,textarea{padding-left: 10px;}
</style>
<div>
    <div class="ibox-content" style="height: 100%;">
        <div style="display: none">
            <input type="hidden" id="idValue" value="">
        </div>
        <div class="row">
            <div style="display:flex;align-items: center">
                <div class="templateText">模板类别：</div>
                <div class="templateFrame">
                    <span id="templateCategory"></span>
                    <button style="border: 1px solid #999999;background: white;padding: 4px 8px;" type="button" class="btn" onclick="choiceTemplate()">点击选择</button>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;line-height: 34px;">
                <div class="templateText">模板名称：</div>
                <div class="templateFrame">
                    <input type="text" name="caseName" id="caseName" style="height: 34px;">
                </div>
            </div>
            <div style="display:flex;margin:12px 0;line-height: 34px;">
                <div class="templateText">主诉：</div>
                <div class="templateFrame">
                    <textarea  name="zhushu" id="zhushu"  style="width: 90%;height: 34px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;line-height: 34px;">
                <div class="templateText">现病史：</div>
                <div class="templateFrame">
                    <textarea name="nowMedicalHistory" id="nowMedicalHistory"  style="width: 90%;height: 34px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;line-height: 34px;">
                <div class="templateText">既往史：</div>
                <div class="templateFrame">
                    <textarea name="beforeMedicalHistory" id="beforeMedicalHistory"  style="width: 90%;height: 34px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;">
                <div class="templateText">口腔检查：</div>
                <div class="templateFrame">
                    <textarea name="mouthCheck"  id="mouthCheck"  style="width: 90%;height: 65px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;">
                <div class="templateText">辅助检查：</div>
                <div class="templateFrame">
                    <textarea name="auxiliaryCheck"  id="auxiliaryCheck"  style="width: 90%;height: 65px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;">
                <div class="templateText">诊断：</div>
                <div class="templateFrame">
                    <textarea name="diagnose"  id="diagnose"  style="width: 90%;height: 65px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;">
                <div class="templateText">治疗方案：</div>
                <div class="templateFrame">
                    <textarea name="remedyPlan"  id="remedyPlan"  style="width: 90%;height: 65px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;">
                <div class="templateText">处置：</div>
                <div class="templateFrame">
                    <textarea name="dispose"  id="dispose"  style="width: 90%;height: 65px;"></textarea>
                </div>
            </div>
            <div style="display:flex;margin:12px 0;line-height: 34px;">
                <div class="templateText">医嘱：</div>
                <div class="templateFrame">
                    <textarea name="doctorAdvice"  id="doctorAdvice"  style="width: 90%;height: 34px;"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div>
        <div style="position: absolute;bottom: 0;width: 100%;background: #efefef;padding: 10px 15px;">
            <div class="btnBox" style="text-align: right">
                <button type="button" class="btn" style="background: white;color: #333333" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name))">取消</button>
                <button type="button" class="btn" onclick="save()">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var remarks1 = window.parent.document.getElementsByClassName("remarks1");
        var remarks2 = window.parent.document.getElementsByClassName("remarks2");
        var remarks3 = window.parent.document.getElementsByClassName("remarks3");
        var remarks4 = window.parent.document.getElementsByClassName("remarks4");
        var remarks5 = window.parent.document.getElementsByClassName("remarks5");

        var a = "",b = "",c = "",d = "",e = "";
        for(var i=0 ; i<remarks1.length ; i++){
            if(remarks1[i].value != ""){
                a += remarks1[i].value + "。"
            }
        }
        for(var u=0 ; u<remarks2.length ; u++){
            if(remarks2[u].value != ""){
                b += remarks2[u].value + "。"
            }
        }
        for(var w=0 ; w<remarks3.length ; w++){
            if(remarks3[w].value != ""){
                c += remarks3[w].value + "。"
            }
        }
        for(var t=0 ; t<remarks4.length ; t++){
            if(remarks4[t].value != ""){
                d += remarks4[t].value + "。"
            }
        }
        for(var l=0 ; l<remarks5.length ; l++){
            if(remarks5[l].value != ""){
                e += remarks5[l].value + "。"
            }
        }

        $("#zhushu").val(window.parent.document.getElementById("zhushu").value);  //主述
        $("#nowMedicalHistory").val(window.parent.document.getElementById("nowMedicalHistory").value);  //现病史
        $("#beforeMedicalHistory").val(window.parent.document.getElementById("beforeMedicalHistory").value);  //既往史
        $("#doctorAdvice").val(window.parent.document.getElementById("doctorAdvice").value);  //医嘱
        $("#mouthCheck").val(a);        //口腔检查
        $("#auxiliaryCheck").val(b);    //辅助检查
        $("#diagnose").val(c);          //辅助检查
        $("#remedyPlan").val(d);        //治疗计划
        $("#dispose").val(e);           //处置
    });

    choiceTemplate = function () {
        var index = layer.open({
            type: 2,
            title: '选择模板类别',
            area: ['50%', '70%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/doctorLooked/doctor_choiceTemplate'
        });
        this.layerIndex = index;
    };

    function save(){
        var oblogid = $("#idValue").val();
        var caseName = $("#caseName").val();  //模板名称
        var zhushu = $("#zhushu").val();  //主诉
        var nowMedicalHistory = $("#nowMedicalHistory").val();  //现病史
        var beforeMedicalHistory = $("#beforeMedicalHistory").val();  //既往史
        var mouthCheck = $("#mouthCheck").val();  //口腔检查
        var auxiliaryCheck = $("#auxiliaryCheck").val();  //辅助检查
        var diagnose = $("#diagnose").val();  //辅助检查
        var remedyPlan = $("#remedyPlan").val();  //治疗计划
        var dispose = $("#dispose").val();  //处置
        var doctorAdvice = $("#doctorAdvice").val();  //医嘱
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/addCaseContent",
            type: "post",
            data: {
                "caseName": caseName,
                "zhushu": zhushu,
                "nowMedicalHistory": nowMedicalHistory,
                "beforeMedicalHistory": beforeMedicalHistory,
                "mouthCheck": mouthCheck,
                "auxiliaryCheck": auxiliaryCheck,
                "diagnose":diagnose,
                "remedyPlan": remedyPlan,
                "dispose": dispose,
                "doctorAdvice": doctorAdvice,
                "oblogid":oblogid
            },
            success: function (data) {
                Feng.success('添加成功!');
                parent.layer.close(parent.layer.getFrameIndex(window.name))
            },
            error: function (data) {
                alert('内部故障!');
            }
        });
    }
</script>
@}
